﻿using System.Data.Entity.ModelConfiguration;

namespace Equation.Enterprise.Framework.Domain.Model
{
    public class EntityMappingWithTypedId<T, TIdType> : EntityTypeConfiguration<T> where T:EntityWithTypedId<TIdType>
    {
        public EntityMappingWithTypedId(string tableName) : this(tableName, "dbo")
        {
        }

        /// <summary>
        /// Base mapping
        /// Point out Id is key. Child class has to point the map to column name.
        /// Point out table name.
        /// Point out schema name.
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="schemaName"></param>
        public EntityMappingWithTypedId(string tableName, string schemaName)
        {
            this.HasKey(x => x.Id);
            this.ToTable(tableName, schemaName);
        }
    }
}
